package com.todo.event.activity.application.convert;

import com.todo.event.activity.application.entity.bo.ActivityRecordBO;
import com.todo.event.activity.application.entity.bo.ActivityRewardRecordBO;
import com.todo.event.activity.application.entity.bo.ActivityTouchRecordBO;
import com.todo.event.activity.common.enums.EventActivityExecuteRewardEnum;
import com.todo.event.activity.common.enums.EventActivityExecuteTouchEnum;
import com.todo.event.activity.common.enums.ExecuteRecordStatusEnum;
import com.todo.common.utils.TodoCommonUtils;
import com.todo.event.activity.infrastructure.entity.po.EventActivityRecordPO;
import com.todo.event.activity.infrastructure.entity.po.EventActivityRewardRecordPO;
import com.todo.event.activity.infrastructure.entity.po.EventActivityTouchRecordPO;

import java.util.Date;

/**
 * @author azhebuxing
 * @date 2025/1/15 15:48
 * @description
 */
public class EventActivityRecordConvert {
    public static EventActivityRecordPO convertToEventActivityRecordPO(ActivityRecordBO activityRecordBO) {
        if (activityRecordBO == null) {
            return null;
        }
        EventActivityRecordPO eventActivityRecordPO = new EventActivityRecordPO();
        eventActivityRecordPO.setId(activityRecordBO.getId() == null ? TodoCommonUtils.buildLongGuid() : activityRecordBO.getId());
        eventActivityRecordPO.setActivityId(activityRecordBO.getActivityId());
        eventActivityRecordPO.setUserId(activityRecordBO.getUserId());
        eventActivityRecordPO.setUk(activityRecordBO.getUk());
        eventActivityRecordPO.setOperateTime(activityRecordBO.getOperateTime());
        eventActivityRecordPO.setStatus(activityRecordBO.getStatus() == null ? ExecuteRecordStatusEnum.EXECUTING.getType() : activityRecordBO.getStatus().getType());
        eventActivityRecordPO.setOriginData(activityRecordBO.getOriginData());
        eventActivityRecordPO.setRetryCount(activityRecordBO.getRetryCount() == null ? 0 : activityRecordBO.getRetryCount());
        eventActivityRecordPO.setIsDelete(0);
        eventActivityRecordPO.setCreateTime(new Date());
        eventActivityRecordPO.setUpdateTime(new Date());
        return eventActivityRecordPO;
    }

    public static EventActivityRewardRecordPO convertToEventActivityRewardRecordPO(ActivityRewardRecordBO activityRewardRecordBO) {
        if (activityRewardRecordBO == null){
            return null;
        }
        EventActivityRewardRecordPO eventActivityRewardRecordPO = new EventActivityRewardRecordPO();
        eventActivityRewardRecordPO.setId(activityRewardRecordBO.getId() == null ? TodoCommonUtils.buildLongGuid() : activityRewardRecordBO.getId());
        eventActivityRewardRecordPO.setActivityId(activityRewardRecordBO.getActivityId());
        eventActivityRewardRecordPO.setUserId(activityRewardRecordBO.getUserId());
        eventActivityRewardRecordPO.setUk(activityRewardRecordBO.getUk());
        eventActivityRewardRecordPO.setRewardType(activityRewardRecordBO.getRewardType() == null ? null : activityRewardRecordBO.getRewardType().getType());
        eventActivityRewardRecordPO.setOperateTime(activityRewardRecordBO.getOperateTime());
        eventActivityRewardRecordPO.setStatus(activityRewardRecordBO.getStatus() == null ? ExecuteRecordStatusEnum.EXECUTING.getType() : activityRewardRecordBO.getStatus().getType());
        eventActivityRewardRecordPO.setOriginData(activityRewardRecordBO.getOriginData());
        eventActivityRewardRecordPO.setRetryCount(activityRewardRecordBO.getRetryCount() == null ? 0 : activityRewardRecordBO.getRetryCount());
        eventActivityRewardRecordPO.setIsDelete(0);
        eventActivityRewardRecordPO.setCreateTime(new Date());
        eventActivityRewardRecordPO.setUpdateTime(new Date());
        return eventActivityRewardRecordPO;
    }

    public static EventActivityTouchRecordPO convertToEventActivityTouchRecordPO(ActivityTouchRecordBO activityTouchRecordBO) {
        if (activityTouchRecordBO == null){
            return null;
        }
        EventActivityTouchRecordPO eventActivityTouchRecordPO = new EventActivityTouchRecordPO();
        eventActivityTouchRecordPO.setId(activityTouchRecordBO.getId() == null ? TodoCommonUtils.buildLongGuid() : activityTouchRecordBO.getId());
        eventActivityTouchRecordPO.setActivityId(activityTouchRecordBO.getActivityId());
        eventActivityTouchRecordPO.setUserId(activityTouchRecordBO.getUserId());
        eventActivityTouchRecordPO.setUk(activityTouchRecordBO.getUk());
        eventActivityTouchRecordPO.setTouchType(activityTouchRecordBO.getTouchType() == null ? null : activityTouchRecordBO.getTouchType().getType());
        eventActivityTouchRecordPO.setOperateTime(activityTouchRecordBO.getOperateTime());
        eventActivityTouchRecordPO.setStatus(activityTouchRecordBO.getStatus() == null ? ExecuteRecordStatusEnum.EXECUTING.getType() : activityTouchRecordBO.getStatus().getType());
        eventActivityTouchRecordPO.setOriginData(activityTouchRecordBO.getOriginData());
        eventActivityTouchRecordPO.setRetryCount(activityTouchRecordBO.getRetryCount() == null ? 0 : activityTouchRecordBO.getRetryCount());
        eventActivityTouchRecordPO.setIsDelete(0);
        eventActivityTouchRecordPO.setCreateTime(new Date());
        eventActivityTouchRecordPO.setUpdateTime(new Date());
        return eventActivityTouchRecordPO;
    }

    public static ActivityRecordBO convertToActivityRecordBO(EventActivityRecordPO eventActivityRecordPO) {
        if (eventActivityRecordPO == null){
            return null;
        }
        ActivityRecordBO activityRecordBO = new ActivityRecordBO();
        activityRecordBO.setId(eventActivityRecordPO.getId());
        activityRecordBO.setActivityId(eventActivityRecordPO.getActivityId());
        activityRecordBO.setUserId(eventActivityRecordPO.getUserId());
        activityRecordBO.setUk(eventActivityRecordPO.getUk());
        activityRecordBO.setOperateTime(eventActivityRecordPO.getOperateTime());
        activityRecordBO.setStatus(ExecuteRecordStatusEnum.getByType(eventActivityRecordPO.getStatus()));
        activityRecordBO.setOriginData(eventActivityRecordPO.getOriginData());
        activityRecordBO.setRetryCount(eventActivityRecordPO.getRetryCount());
        return activityRecordBO;
    }

    public static ActivityRewardRecordBO convertToActivityRewardRecordBO(EventActivityRewardRecordPO eventActivityRewardRecordPO) {
        if (eventActivityRewardRecordPO == null){
            return null;
        }
        ActivityRewardRecordBO activityRewardRecordBO = new ActivityRewardRecordBO();
        activityRewardRecordBO.setId(eventActivityRewardRecordPO.getId());
        activityRewardRecordBO.setActivityId(eventActivityRewardRecordPO.getActivityId());
        activityRewardRecordBO.setUserId(eventActivityRewardRecordPO.getUserId());
        activityRewardRecordBO.setUk(eventActivityRewardRecordPO.getUk());
        activityRewardRecordBO.setRewardType(EventActivityExecuteRewardEnum.getByType(eventActivityRewardRecordPO.getRewardType()));
        activityRewardRecordBO.setOperateTime(eventActivityRewardRecordPO.getOperateTime());
        activityRewardRecordBO.setStatus(ExecuteRecordStatusEnum.getByType(eventActivityRewardRecordPO.getStatus()));
        activityRewardRecordBO.setOriginData(eventActivityRewardRecordPO.getOriginData());
        activityRewardRecordBO.setRetryCount(eventActivityRewardRecordPO.getRetryCount());
        return activityRewardRecordBO;
    }

    public static ActivityTouchRecordBO convertToActivityTouchRecordBO(EventActivityTouchRecordPO eventActivityTouchRecordPO) {
        if (eventActivityTouchRecordPO == null){
            return null;
        }
        ActivityTouchRecordBO activityTouchRecordBO = new ActivityTouchRecordBO();
        activityTouchRecordBO.setId(eventActivityTouchRecordPO.getId());
        activityTouchRecordBO.setActivityId(eventActivityTouchRecordPO.getActivityId());
        activityTouchRecordBO.setUserId(eventActivityTouchRecordPO.getUserId());
        activityTouchRecordBO.setUk(eventActivityTouchRecordPO.getUk());
        activityTouchRecordBO.setTouchType(EventActivityExecuteTouchEnum.getByType(eventActivityTouchRecordPO.getTouchType()));
        activityTouchRecordBO.setOperateTime(eventActivityTouchRecordPO.getOperateTime());
        activityTouchRecordBO.setStatus(ExecuteRecordStatusEnum.getByType(eventActivityTouchRecordPO.getStatus()));
        activityTouchRecordBO.setOriginData(eventActivityTouchRecordPO.getOriginData());
        activityTouchRecordBO.setRetryCount(eventActivityTouchRecordPO.getRetryCount());
        return activityTouchRecordBO;
    }
}
